<section class="sms-page" id="sms-page">
    <div id="left" class="span3" data-bind="visible: secondMenu().length > 0" style="">
        <ul id="leftmenu" data-bind="foreach: {data: secondMenu }">
            <li data-bind="visible: false, text: $root.getThirdMenu($data)" style="display: none;"></li>
            <li data-bind="attr: {'class': 'menu-two-level ' + hash.substring(1) }" class="menu-two-level smslist">
                <a data-bind="attr: {href: hash, trans: hash.substring(1)}" href="#sms_router" trans="smslist">Router SMS</a>
            </li>
            <li data-bind="visible: $root.thirdMenu().length > 0" class="hide" style="display: none;">
                <ul class="third" data-bind="foreach: $root.thirdMenu()"></ul>
            </li>

            <li data-bind="visible: false, text: $root.getThirdMenu($data)" style="display: none;"></li>
            <li data-bind="attr: {'class': 'menu-two-level ' + hash.substring(1) }" class="menu-two-level sim_messages">
                <a data-bind="attr: {href: hash, trans: hash.substring(1)}" href="#sms_sim" trans="sim_messages">SIM SMS</a>
            </li>
            <li data-bind="visible: $root.thirdMenu().length > 0" class="hide" style="display: none;">
                <ul class="third" data-bind="foreach: $root.thirdMenu()"></ul>
            </li>

            <li data-bind="visible: false, text: $root.getThirdMenu($data)" style="display: none;"></li>
            <li data-bind="attr: {'class': 'menu-two-level ' + hash.substring(1) }" class="menu-two-level sms_setting">
                <a data-bind="attr: {href: hash, trans: hash.substring(1)}" href="#sms_settings" trans="sms_setting">SMS Settings</a>
            </li>
            <li data-bind="visible: $root.thirdMenu().length > 0" class="hide" style="display: none;">
                <ul class="third" data-bind="foreach: $root.thirdMenu()"></ul>
            </li>
        </ul>
    </div>

    <div id="containerSms">
    </div>
</section>

<script>
    $(function() {
        $("#list-nav").find(".active").removeClass("active")
        $("#list-nav").find("[mid='sms_router']").addClass("active");

        var currentTopic = window.location.hash;
        var match = window.findSettingsMenu(currentTopic);
        if (match.length == 0) {
            if (!window.location.hash.indexOf('http') == 0) {
                window.location.hash = '#home'
            }
        } else {
            if (window._noSIM == true && match[0].checkSIMStatus) {
                $('#containerSms').html('<div class="colorRed font18" style="padding: 20px; text-align: center">' + $.i18n.prop('no_sim_card_message') + '</div>');
            } else {
                var toUrl = match[0].path + '.html';
                $('#containerSms').load(toUrl)
            }
        }

        var currentNode = $('a[href="' + currentTopic + '"]');
        currentNode.parent().addClass('active');
        var parentList = currentNode.parents('.list');
        if (parentList.length != 0) {
            $(parentList[0]).addClass('active');
            $(parentList).find('.sub-list-wrap').show();
        }

        $('#sms-page').translate()
    });
</script>